package com.polaris.live.dialog_fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.gyf.immersionbar.ImmersionBar
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.common.util.NavigationBarUtils
import com.polaris.live.databinding.PopupTaskDialogFragmentBinding
import com.polaris.live.ui.message.fragment.dialog.BottomDialogFragment
import com.polaris.live.ui.user.task.TaskCenterDialogFragment
import com.polaris.live.utils.fragment.attachFragment

/**
 * TaskDialogFragment
 *
 * @author Created by 天晴 on 2024/10/29 14:35
 * @since 1.0.0
 **/
class TaskDialogFragment : BottomDialogFragment() {
    private lateinit var mBinding: PopupTaskDialogFragmentBinding
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        mBinding = PopupTaskDialogFragmentBinding.inflate(inflater, container, false)
        return mBinding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
        val bottomView = mBinding.bottomView
        val lp = bottomView.layoutParams as ViewGroup.LayoutParams
        lp.height = NavigationBarUtils.getNavigationBarHeight(requireContext())
        bottomView.layoutParams = lp
    }

    override fun initImmersionBar() {
        ImmersionBar.with(this)
            .statusBarDarkFont(true)
            .navigationBarDarkIcon(true)
            .transparentNavigationBar()
            .init()
    }

    private fun initView() {
        mBinding.root.setOnSingleClickListener {
            dismiss()
        }
        mBinding.flFragment.setOnSingleClickListener {
        }
        childFragmentManager.attachFragment(com.polaris.live.R.id.fl_fragment) {
            TaskCenterDialogFragment().apply {
                setDismissBack {
                    dismiss()
                }
            }
        }
    }

    companion object {

        const val TAG = "TaskDialogFragment"
    }
}